;;;; init-python  -  Python programming language settings 
;;;;
;;;;  Evgeniy Sharapov, evgeniy.sharapov@gmail.com 
;;;;
;;;;
(require 'pymacs nil t)
(eval-after-load "python"
  '(progn
     (define-key python-mode-map (kbd "RET") 'newline-and-indent)
;;; (when (require 'pymacs nil t) (pymacs-load "ropemacs" "rope-"))
;;; (define-key ropemacs-local-keymap (kbd "M-/") 'dabbrev-expand)
;;; (defun rope-reload ()
;;; (interactive)
;;; (pymacs-terminate-services)
;;; (pymacs-load "ropemacs" "rope-"))
     ))

;;  my stuff that worked before 
;; (eval-after-load "pymacs"
;;   '(progn
;;      (require 'compile)
;;      (when (load "flymake" t)
;;        (defun flymake-pylint-init ()
;;          (let* ((temp-file (flymake-init-create-temp-buffer-copy
;;                             'flymake-create-temp-inplace))
;;                 (local-file (file-relative-name
;;                              temp-file
;;                              (file-name-directory buffer-file-name))))
;;            (list "epylint" (list local-file))))
;;        (add-to-list 'flymake-allowed-file-name-masks
;;                     '("\\.py\\'" flymake-pylint-init)))
;;      (defun pylint-python-hook ()
;;        "adapted from pychecker for pylint"
;;        (defun pylint ()
;;          "Run pylint against the file behind the current buffer after  checking if unsaved buffers should be saved."
;;          (interactive)
;;          (let* ((file (buffer-file-name (current-buffer)))
;;                 (command (concat "pylint --output-format=parseable \"" file "\"")))
;;            (save-some-buffers (not compilation-ask-about-save) nil) ; save  files.
;;            (compile-internal command "No more errors or warnings" "pylint")))
;;                                         ;  (local-set-key [f1] 'pylint)
;;                                         ;  (local-set-key [f2] 'previous-error)
;;                                         ;  (local-set-key [f3] 'next-error)
;;        (define-key
;;          py-mode-map
;;          [menu-bar Python pylint-separator]
;;          '("--" . pylint-seperator))
;;        (define-key
;;          py-mode-map
;;          [menu-bar Python next-error]
;;          '("Next error" . next-error))
;;        (define-key
;;          py-mode-map
;;          [menu-bar Python prev-error]
;;          '("Previous error" . previous-error))
;;        (define-key
;;          py-mode-map
;;          [menu-bar Python lint]
;;          '("Pylint" . pylint))))
  
(defun sen:python-hooks ()
  (linum-mode 1)
  (highlight-symbol-mode 1)
  (outline-minor-mode t)   ;; outline for python
  (eval-after-load "pymacs"
    '(progn
       (pymacs-load "ropemacs" "rope-") ; ROPE - for refactoring and auto-completion
       (ropemacs-mode 1) ; all these nice features
       ))
  (show-paren-mode 1)
  (reveal-mode 1)
  (eldoc-mode 1))

(add-hook 'python-mode-hook 'sen:python-hooks)
  
  
(provide 'init-python)